import akshare as ak

# hist_df = ak.stock_us_daily(symbol="AMZN")
# print(hist_df)


print("###################")

"""
定义函数时，参数的顺序为：必选参数-》默认参数-》可选参数-》关键字参数-》命名关键字参数
"""

# 关键字参数
def person(name, age, **kw):
    print(str(age))
    print("name:" + name + ",age:" + str(age) + ",other:" + str(kw))

# 命名关键字参数(命名关键字参数会覆盖关键字参数)
def person(name, age, *, city, job):
    print("name:", name, "age:", age, "city:", city, "job:", job)

# 命名关键字参数前面如果有可变参数，则不需要在前面添加*
def person(name, age, *args, city="shenzhen", job):
    print(name, age, args, city, job)

# 递归函数
def fact(n):
    if n == 1:
        return 1
    else:
        return fact(n - 1) * n

# 去掉字符串前后的空格
def trim(s):
    if(len(s) == 0):
        return s
    while s[0:1] == ' ':
        print("前缀处理", s)
        return trim(s[1:])
    while s[-1] == ' ':
        print("后缀处理", s)
        return trim(s[:-1])
    return s

# person("zhangsan", 18, city = 'shannxi province', nation = 'China')

# person("lisi", 20, city="shagnhai", job="programmer")

# person("wangwu", 99, 'China', job="artist")

# print(fact(10))

# L = ['zhangsan', 'lisi', 'wangwu']
# # print(L[-2:])

# L = list(range(100))
# print(L[::5])

# if trim('hello  ') != 'hello':
#     print('测试失败!')
# elif trim('  hello') != 'hello':
#     print('测试失败!')
# elif trim('  hello  ') != 'hello':
#     print('测试失败!')
# elif trim('  hello  world  ') != 'hello  world':
#     print('测试失败!')
# elif trim('') != '':
#     print('测试失败!')
# elif trim('    ') != '':
#     print('测试失败!')
# else:
#     print('测试成功!')

